<template>
	<view>
		<uni-section title="功能列表" sub-title="" type="square">
		</uni-section>
		<swiper :indicator-dots="true" :autoplay="true" :interval="3000" :duration="1000" class="com">
			<swiper-item>
				<view class="comment">
					<uni-list>
						<uni-list-item v-for="item,index in list" :key="index" :title="item.title"></uni-list-item>
					</uni-list>
				</view>
			</swiper-item>
			<swiper-item>
				<uni-grid :column="5">
					<uni-grid-item class="grid" v-for="item,index in data" :key="index">
						<view>
							<image :src='"/static"+item.icon' mode="aspectFill" class="img"></image>
						</view>
						<text>{{item.functionname}}</text>
					</uni-grid-item>
				</uni-grid>
			</swiper-item>
		</swiper>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				list: [{
					"id": 1,
					"title": "",
					"description": "",
					"date": ""
				}],
				data: [{
					"id": 1,
					"functionname": "",
					"icon": ""
				}],
			}
		},
		onLoad() {
			uni.showLoading({
				title: '加载中',
				mask: false
			});
			//公告
			uni.request({
				url: 'http://localhost:8090/freshmenapp/announcement/list',
				method: 'POST',
				data: {},
				success: res => {
					console.log(res);
					this.list = res.data.list;
					uni.showToast({
						title: '成功'
					});
					setTimeout(() => {
						uni.hideLoading()
					}, 2000)
				},
				fail: () => {
					uni.showToast({
						title: '失败',
						icon: 'none'
					});
				},
				complete: () => {}
			});
			//功能
			uni.request({
				url: 'http://localhost:8090/freshmenapp/function/list',
				method: 'POST',
				data: {},
				success: res2 => {
					console.log(res2);
					this.data = res2.data.data;
					uni.showToast({
						title: '成功'
					});
					setTimeout(() => {
						uni.hideLoading()
					}, 2000)
				},
				fail: () => {
					uni.showToast({
						title: '失败',
						icon: 'none'
					});
				},
				complete: () => {}
			});
		},
		methods: {}
	}
</script>

<style>
	.container {
		font-size: 14px;
		line-height: 24px;
	}

	.swiper-item {
		width: 100%;
		height: 240px;
	}

	.swiper-item image {
		width: 100%;
		height: 100%;
	}

	.comment-a {
		width: 100%;
		height: 100px;
	}


	.grid {
		text-align: center;
	}

	.grid text {
		font-size: 14px;
		color: #666;
		margin-top: -10px;
	}

	.img {
		width: 45px;
		height: 45px;
	}
</style>